<?php
/*
 * Created on 03.07.2008
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
 class Common {
 	
 	protected $template;
	protected $object_types = array();
 	
 	function init($template) {
 		$this->template = $template;
		$this->object_types =
		    array(
			news => 1
		    );
 	}	
 	
 	function assignCommon($template) {
 		
	    $this->init($template);

	    $_route = $template->getArg('_ROUTE');

	    if(!$this->template->arguments['_user']) {
		$this->template->arguments['_user'] = new Model_User();
	    }
	
	    $menu = new Model_Menu();
	 

	    if($this->template->arguments['_user']) {
		    $this->template->arguments['is_logged']		= $this->template->arguments['_user']->is_logged() ? true : false;
	    }
		
    	    $this->template->arguments['realname']		= $this->template->arguments['_user']->realname;
    	    $this->template->arguments['user_name']		= $this->template->arguments['_user']->login;
    	    $this->template->arguments['_email']		= $this->template->arguments['_user']->email;

    	    $this->template->arguments['BASE_URL']		= hostname;
    	
    	    $site = new Model_Site();
    	
    	    $this->template->arguments['header_text'] 	= $site->header;
    	    $this->template->arguments['footer_text'] 	= $site->footer;
    	    
            if (!$this->template->arguments['_TITLE']) {
                $this->template->arguments['_TITLE']		= $this->template->arguments['content']->title ?  $this->template->arguments['content']->title : $site->title;
            }
    	
    	    $this->template->arguments['site']			= $site;

			Catalog::init();

    	    $this->template->arguments['object_types']  = Catalog::types();
    	    
    	    if(empty($this->template->arguments['menu']))
    	    	$this->template->arguments['menu'] 		=  $menu->getMenu(1);
    	    
            $this->template->arguments['left_menu'] = $menu->getMenu($menu->getIdByAlias('realty'));
            $this->template->arguments['menu_info'] = $menu->getMenu($menu->getIdByAlias('information'));
            $this->template->arguments['menu_city'] = Catalog::cities();//$menu->getMenu($menu->getIdByAlias('city'));
 	}
 	
 }
 
?>
